const app = getApp()
import { currentDates, time, timeBefter } from '../../utils/util'
Page({
  data: {
    imgurl: app.globalData.imgurl,
  },
  onLoad({ o_id }) {
    this._getData(o_id)
  },
  async _getData(o_id) {
    let { code, data } = await wx.requestAsync({
      url: '/order/detail',
      data: {
        o_id,
      },
    })
    if (code == 0) {
      if (data.spell.begin_at) {
        let date = (data.spell.begin_at =
          currentDates(data.spell.begin_at * 1000) +
          ' ' +
          time(data.spell.begin_at) +
          '-' +
          time(data.spell.end_at))
        this.setData({
          date,
        })
        console.log(1)
      } else {
        let date =
          currentDates(data.parent.pre_at * 1000) +
          ' ' +
          time(data.parent.pre_at) +
          '-' +
          timeBefter(data.parent.pre_at, data.parent.hour)
        this.setData({
          date,
        })
      }
      this.setData(data)
    }
  },
})
